package com.wdb007.venus.svc.biz.manager;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.github.wxpay.sdk.WXPayConfig;

@Component
public class WeChatPayConfig implements WXPayConfig {
	
	@Autowired
	private ConfigInfoManager configInfoManager;
	
	@Override
	public String getAppID() {
		return configInfoManager.getValue("wechat.appid");
	}

	@Override
	public InputStream getCertStream() {
		try {
			return new FileInputStream(
					new File(configInfoManager.getValue("wechat.certpath")));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public int getHttpConnectTimeoutMs() {
		return 6*1000;
	}

	@Override
	public int getHttpReadTimeoutMs() {
		return 8*1000;
	}

	@Override
	public String getKey() {
		return configInfoManager.getValue("wechat.key");
	}

	@Override
	public String getMchID() {
		return configInfoManager.getValue("wechat.mch_id");
	}

}
